home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpdata / simpmain / 00002_interfaceManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-06  |  9.1 KB  |  232 lines

  1. property panelCastNum, panelCastNumLst, btnBoundsLst, btnActionLst, btnSoundLst, btnPosLst, btnCastNumLst, btnSelCastNumLst, topPanelCastNumLst, bottomPanelCastNumLst, rightPanelCastNumLst, leftPanelCastNumLst
  2. global gPlayFlag, gLoopFlag, topPanelSpr, bottomPanelSpr, leftPanelSpr, rightPanelSpr, shuttleSpr, shuttleFldSpr, playBtnSpr, loopBtnSpr, fileNameFieldSpr, loopStatusFieldSpr, soundStatusFieldSpr, buttonHiliteSpr, currentFrame
  3.  
  4. on birth me
  5.   set topPanelSpr to 24
  6.   set bottomPanelSpr to topPanelSpr + 1
  7.   set leftPanelSpr to topPanelSpr + 2
  8.   set rightPanelSpr to topPanelSpr + 3
  9.   set buttonHiliteSpr to topPanelSpr + 4
  10.   set shuttleSpr to topPanelSpr + 5
  11.   set shuttleFldSpr to topPanelSpr + 6
  12.   set playBtnSpr to topPanelSpr + 7
  13.   set loopBtnSpr to topPanelSpr + 8
  14.   set fileNameFieldSpr to topPanelSpr + 9
  15.   set loopStatusFieldSpr to topPanelSpr + 10
  16.   set soundStatusFieldSpr to topPanelSpr + 11
  17.   puppetSprites(topPanelSpr, soundStatusFieldSpr, 1)
  18.   set gLoopFlag to 0
  19.   set gPlayFlag to 0
  20.   set panelCastNumLst to [#topPanelSpr: the number of cast "top panel base", #bottomPanelSpr: the number of cast "bottom panel base", #rightPanelSpr: the number of cast "right panel base", #leftPanelSpr: the number of cast "left panel base"]
  21.   set topPanelCastNumLst to [the number of cast "new hilite", the number of cast "open hilite", the number of cast "save hilite", the number of cast "save as hilite", the number of cast "quit hilite"]
  22.   set rightPanelCastNumLst to [the number of cast "homer hilite", the number of cast "marge hilite", the number of cast "bart hilite", the number of cast "lisa hilite", the number of cast "maggie hilite", the number of cast "cameo hilite", the number of cast "props hilite", the number of cast "soundFX hilite", the number of cast "specialFX hilite", the number of cast "backgrounds hilite"]
  23.   set bottomPanelCastNumLst to [the number of cast "rewind hilite", the number of cast "fastforward hilite", the number of cast "stepback hilite", the number of cast "stepforward hilite", the number of cast "cut hilite"]
  24.   set leftPanelCastNumLst to [the number of cast "memory hilite", the number of cast "volume hilite", the number of cast "export hilite"]
  25.   set btnSelCastNumLst to [the number of cast "homer selected", the number of cast "marge selected", the number of cast "bart selected", the number of cast "lisa selected", the number of cast "maggie selected", the number of cast "cameo selected", the number of cast "props selected", the number of cast "soundFX selected", the number of cast "specialFX selected", the number of cast "backgrounds selected"]
  26.   return me
  27. end
  28.  
  29. on panelClick me, theMouseH, theMouseV, whichSpr
  30.   set panelSeqLst to ["top", "bottom", "left", "right"]
  31.   set panelPrefix to getAt(panelSeqLst, whichSpr - topPanelSpr + 1)
  32.   set panelCastNum to getaProp(panelCastNumLst, value("#" & panelPrefix & "PanelSpr"))
  33.   set btnCastNumLst to value(panelPrefix & "PanelCastNumLst")
  34.   set btnBoundsLst to value(line 1 of field (panelPrefix & "PanelData"))
  35.   set btnPosLst to value(line 2 of field (panelPrefix & "PanelData"))
  36.   set btnActionLst to value(line 3 of field (panelPrefix & "PanelData"))
  37.   set btnSoundLst to value(line 4 of field (panelPrefix & "PanelData"))
  38.   if panelPrefix = "right" then
  39.     set clickType to #TOGGLE
  40.   else
  41.     set clickType to #NORMAL
  42.   end if
  43.   buttonClick(me, theMouseH, theMouseV, whichSpr, clickType)
  44. end
  45.  
  46. on buttonClick me, theMouseH, theMouseV, whichSpr, clickType
  47.   set theMouseH to theMouseH - the left of sprite whichSpr
  48.   set theMouseV to theMouseV - the top of sprite whichSpr
  49.   set theMouseLoc to point(theMouseH, theMouseV)
  50.   if soundBusy(2) then
  51.     puppetSound(2, 0)
  52.   end if
  53.   repeat with buttonNum = 1 to count(btnBoundsLst)
  54.     set theButtonBounds to getAt(btnBoundsLst, buttonNum)
  55.     if inside(theMouseLoc, theButtonBounds) then
  56.       set soundCastNum to the number of cast getAt(btnSoundLst, buttonNum)
  57.       puppetSound(2, soundCastNum)
  58.       set hiliteCastNum to getAt(btnCastNumLst, buttonNum)
  59.       set hiliteButtonLoc to getAt(btnPosLst, buttonNum)
  60.       set the castNum of sprite buttonHiliteSpr to hiliteCastNum
  61.       set the loc of sprite buttonHiliteSpr to hiliteButtonLoc
  62.       set the width of sprite buttonHiliteSpr to the width of cast hiliteCastNum
  63.       set the height of sprite buttonHiliteSpr to the height of cast hiliteCastNum
  64.       updateStage()
  65.       set hilite to 1
  66.       startTimer()
  67.       repeat while the timer < 6
  68.       end repeat
  69.       if the mouseDown then
  70.         repeat while the mouseDown
  71.           set theMouseH to the mouseH - the left of sprite whichSpr
  72.           set theMouseV to the mouseV - the top of sprite whichSpr
  73.           set theMouseLoc to point(theMouseH, theMouseV)
  74.           if inside(theMouseLoc, theButtonBounds) then
  75.             set the loc of sprite buttonHiliteSpr to hiliteButtonLoc
  76.             set hilite to 1
  77.           else
  78.             set the locH of sprite buttonHiliteSpr to -1000
  79.             set hilite to 0
  80.           end if
  81.           updateStage()
  82.         end repeat
  83.       end if
  84.       if hilite then
  85.         if clickType = #TOGGLE then
  86.           unLoadCast(soundCastNum)
  87.           set hiliteCastNum to getAt(btnSelCastNumLst, buttonNum)
  88.           set hiliteButtonLoc to getAt(btnPosLst, buttonNum)
  89.           set the castNum of sprite buttonHiliteSpr to hiliteCastNum
  90.           set the loc of sprite buttonHiliteSpr to hiliteButtonLoc
  91.           set the width of sprite buttonHiliteSpr to the width of cast hiliteCastNum
  92.           set the height of sprite buttonHiliteSpr to the height of cast hiliteCastNum
  93.           updateStage()
  94.         else
  95.           unLoadCast(soundCastNum)
  96.           unLoadCast(hiliteCastNum)
  97.           set the locH of sprite buttonHiliteSpr to -1000
  98.           updateStage()
  99.         end if
  100.         cursor(4)
  101.         do(getAt(btnActionLst, buttonNum))
  102.         cursor(-1)
  103.       else
  104.         unLoadCast(soundCastNum)
  105.         unLoadCast(hiliteCastNum)
  106.         set the locH of sprite buttonHiliteSpr to -1000
  107.         updateStage()
  108.       end if
  109.       exit repeat
  110.     end if
  111.   end repeat
  112. end
  113.  
  114. on loopBtnClick me
  115.   set hilit to 1
  116.   if gLoopFlag then
  117.     set direction to -1
  118.   else
  119.     set direction to 1
  120.   end if
  121.   set theCastNum to the castNum of sprite loopBtnSpr
  122.   set the castNum of sprite loopBtnSpr to theCastNum + direction
  123.   updateStage()
  124.   repeat while the mouseDown
  125.     if rollOver(loopBtnSpr) then
  126.       set the castNum of sprite loopBtnSpr to theCastNum + direction
  127.       set hilit to 1
  128.     else
  129.       set the castNum of sprite loopBtnSpr to theCastNum
  130.       set hilit to 0
  131.     end if
  132.     updateStage()
  133.   end repeat
  134.   if hilit then
  135.     set gLoopFlag to not gLoopFlag
  136.   end if
  137. end
  138.  
  139. on playBtnClick me
  140.   set hilit to 1
  141.   if gPlayFlag then
  142.     set direction to -1
  143.     set soundCastNum to the number of cast "stop snd"
  144.     puppetSound(2, soundCastNum)
  145.   else
  146.     set direction to 1
  147.     set soundCastNum to the number of cast "play snd"
  148.     puppetSound(2, soundCastNum)
  149.   end if
  150.   set theCastNum to the castNum of sprite playBtnSpr
  151.   set the castNum of sprite playBtnSpr to theCastNum + 1
  152.   updateStage()
  153.   if the mouseDown then
  154.     repeat while the mouseDown
  155.       if rollOver(playBtnSpr) then
  156.         set the castNum of sprite playBtnSpr to theCastNum + 1
  157.         set hilit to 1
  158.       else
  159.         set the castNum of sprite playBtnSpr to theCastNum
  160.         set hilit to 0
  161.       end if
  162.       updateStage()
  163.     end repeat
  164.   end if
  165.   unLoadCast(theCastNum + 1)
  166.   unLoadCast(soundCastNum)
  167.   if hilit then
  168.     set the castNum of sprite playBtnSpr to theCastNum + (2 * direction)
  169.     set gPlayFlag to not gPlayFlag
  170.   else
  171.     set the castNum of sprite playBtnSpr to theCastNum
  172.   end if
  173.   updateStage()
  174.   if gPlayFlag then
  175.     if the shiftDown then
  176.       preview(playbackMgr)
  177.     else
  178.       playBackClip(playbackMgr, currentFrame)
  179.     end if
  180.   end if
  181. end
  182.  
  183. on resetPanel me
  184.   set the locH of sprite buttonHiliteSpr to -1000
  185.   updateStage()
  186. end
  187.  
  188. on forcePlayBtnClick me
  189.   if not gPlayFlag then
  190.     set soundCastNum to the number of cast "play snd"
  191.     puppetSound(2, soundCastNum)
  192.     set theCastNum to the castNum of sprite playBtnSpr
  193.     set the castNum of sprite playBtnSpr to theCastNum + 1
  194.     updateStage()
  195.     startTimer()
  196.     repeat while the timer < 6
  197.     end repeat
  198.     unLoadCast(theCastNum + 1)
  199.     unLoadCast(soundCastNum)
  200.     set the castNum of sprite playBtnSpr to theCastNum + 2
  201.     set gPlayFlag to not gPlayFlag
  202.     updateStage()
  203.     if the shiftDown then
  204.       preview(playbackMgr)
  205.     else
  206.       playBackClip(playbackMgr, currentFrame)
  207.     end if
  208.   end if
  209. end
  210.  
  211. on forceBtnClick me, soundCastName, hiliteCastName, hiliteButtonLoc, buttonAction
  212.   set soundCastNum to the number of cast soundCastName
  213.   puppetSound(2, soundCastNum)
  214.   set hiliteCastNum to the number of cast hiliteCastName
  215.   set the castNum of sprite buttonHiliteSpr to hiliteCastNum
  216.   set the loc of sprite buttonHiliteSpr to hiliteButtonLoc
  217.   set the width of sprite buttonHiliteSpr to the width of cast hiliteCastNum
  218.   set the height of sprite buttonHiliteSpr to the height of cast hiliteCastNum
  219.   set hilite to 1
  220.   updateStage()
  221.   startTimer()
  222.   repeat while the timer < 6
  223.   end repeat
  224.   set the locH of sprite buttonHiliteSpr to -1000
  225.   updateStage()
  226.   unLoadCast(soundCastNum)
  227.   unLoadCast(hiliteCastNum)
  228.   cursor(4)
  229.   do(buttonAction)
  230.   cursor(-1)
  231. end
  232.